﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;


namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class DatHangOnlineBlo
    {
        #region "Khai báo các biến"
        private DatHangOnlineDAO da;
        private DatHangOnlineDTO _DHOL;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public DatHangOnlineDTO DHOL
        {
            get { return _DHOL; }
            set { _DHOL = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public DatHangOnlineBlo()
        {            
            da = new DatHangOnlineDAO();
        }
        public bool InsertDHOL(string MaDHOL, string MaTKOL, DateTime NgayDatHang, string Hinhthucthanhtoan, string Trangthai, double Tongtien)
        {
            _DHOL = new DatHangOnlineDTO(MaDHOL, MaTKOL, NgayDatHang,Hinhthucthanhtoan,Trangthai,Tongtien);
            if (!da.InsertDHOL(DHOL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateDHOL(string MaDHOL, string MaTKOL, DateTime NgayDatHang, string Hinhthucthanhtoan, string Trangthai, double Tongtien)
        {
            _DHOL = new DatHangOnlineDTO(MaDHOL, MaTKOL, NgayDatHang, Hinhthucthanhtoan, Trangthai, Tongtien);
            if (!da.UpdateDHOL(DHOL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteDHOL(string MaDHOL)
        {
            if (!da.DeleteDHOL(MaDHOL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_DatHangOnline()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_DatHangOnline();
            return ds;
        }
        #endregion 
    }
}